Focusing method and apparatus, electronic device, and medium

ABSTRACT

This application discloses a focusing method and apparatus, an electronic device, and a medium. The focusing method includes: receiving first input when a first preview image captured based on a first zoom ratio is displayed, where the first input is used for triggering an update of the first zoom ratio to a second zoom ratio, the first zoom ratio is less than the second zoom ratio, and the first preview image includes an image of a target object; capturing N images based on the first zoom ratio in response to the first input; capturing an image of the target object from each of the N images based on the second zoom ratio, to obtain N sub-images; and synthesizing the N sub-images into a second preview image, and displaying the second preview image, where N is an integer greater than 1.

CROSS-REFERENCE TO RELATED APPLICATIONS

This application is a continuation of International Application No.PCT/CN2022/073035, filed Jan. 20, 2022, which claims priority to ChinesePatent Application 202110113859.3, filed Jan. 27, 2021. The entirecontents of each of the above-referenced applications are expresslyincorporated herein by reference.

TECHNICAL FIELD

This application relates to the field of photographing technologies, andspecifically, relates to a focusing method and apparatus, an electronicdevice, and a medium.

BACKGROUND

A zoom function, also referred to as a zoom-in-and-out function, hasbecome an indispensable function of a terminal device. The focal lengthof a lens may be changed through a change of a lens combination, so thata size of an object in an image is changed, and zoom-in and zoom-outeffects are achieved. Usually, focusing needs to be performed afterzooming, and therefore is referred to zoom-focusing.

Currently, a center focusing manner is usually used in zoom-focusing.After receiving a zoom-in operation performed by a user on an initialpreview interface, a terminal device starts to enlarge an image at acenter point of the initial preview interface. However, when an objectof the user's interest is not at the center point of the initial previewinterface, a recaptured preview interface may not include the object.Therefore, the user may need to move the terminal device back and forthin directions such as up, down, left, and right, so that the object isat the center point of the initial preview interface, and the recapturedpreview interface includes the object. As a result, a zoom-focusingprocess is complex.

SUMMARY

An objective of embodiments of this application is to provide a focusingmethod and apparatus, an electronic device, and a medium.

According to a first aspect, embodiments of this application provide afocusing method. The method includes: receiving first input in a casethat a first preview image captured based on a first zoom ratio isdisplayed, where the first input is used for triggering an update of thefirst zoom ratio to a second zoom ratio, the first zoom ratio is lessthan the second zoom ratio, and the first preview image includes animage of a target object; capturing N images based on the first zoomratio in response to the first input; capturing an image of the targetobject from each of the N images based on the second zoom ratio, toobtain N sub-images; and synthesizing the N sub-images into a secondpreview image, and displaying the second preview image, where N is aninteger greater than 1.

According to a second aspect, embodiments of this application provide azoom-focusing apparatus. The apparatus includes a receiving module, acapture module, a processing module, and a display module. The receivingmodule is configured to receive first input in a case that the displaymodule displays a first preview image captured based on a first zoomratio, where the first input is used for triggering an update of thefirst zoom ratio to a second zoom ratio, the first zoom ratio is lessthan the second zoom ratio, and the first preview image includes animage of a target object. The capture module is configured to capture Nimages based on the first zoom ratio in response to the first inputreceived by the receiving module. The processing module is configuredto: capture, based on the second zoom ratio, an image of the targetobject from each of the N images captured by the capture module, toobtain N sub-images, and synthesize the N sub-images into a secondpreview image. The display module is configured to display the secondpreview image obtained by the processing module through synthesis. N isan integer greater than 1.

According to a third aspect, embodiments of this application provide anelectronic device, where the electronic device includes a processor, amemory, and a program or instructions stored in the memory and capableof running on the processor, and when the program or instructions areexecuted by the processor, the steps of the method provided in the firstaspect are implemented.

According to a fourth aspect, embodiments of this application provide areadable storage medium, where the readable storage medium stores aprogram or instructions, and when the program or instructions areexecuted by a processor, the steps of the method provided in the firstaspect are implemented.

According to a fifth aspect, embodiments of this application provide achip, where the chip includes a processor and a communicationsinterface, the communications interface is coupled to the processor, andthe processor is configured to run a program or instructions toimplement the method provided in the first aspect.

According to a sixth aspect, embodiments of this application provide acomputer program product, where the computer program product is executedby at least one processor to implement the method provided in the firstaspect.

In the embodiments of this application, first input may be received in acase that a first preview image captured based on a first zoom ratio isdisplayed, where the first input is used for triggering an update of thefirst zoom ratio to a second zoom ratio, the first zoom ratio is lessthan the second zoom ratio, and the first preview image includes animage of a target object; N images are captured based on the first zoomratio in response to the first input; an image of the target object iscaptured from each of the N images based on the second zoom ratio, toobtain N sub-images; and the N sub-images are synthesized into a secondpreview image, and the second preview image is displayed. In thissolution, the first preview image captured based on the first zoom ratioincludes the image of the target object. Therefore, when a userincreases a zoom ratio of a lens from the first zoom ratio to the secondzoom ratio, a plurality of images may be captured based on the firstzoom ratio, a sub-image of the target object is captured from each ofthe plurality of images based on the second zoom ratio, and a pluralityof captured sub-images are synthesized into the second preview image. Inthis way, after zoom-focusing is performed, the image of the targetobject can be located in a center area of the second preview image, andthe user does not need to manually change a location of a terminaldevice, thereby simplifying a zoom-focusing process.

BRIEF DESCRIPTION OF DRAWINGS

FIG. 1 is a schematic diagram of a focusing method according to anembodiment of this application;

FIG. 2 is a schematic diagram of an operation of adjusting a zoom ratioaccording to an embodiment of this application;

FIG. 3 is a schematic diagram of a shooting object of a first previewimage according to an embodiment of this application;

FIG. 4A is a first schematic diagram of determining a target area and afocusing area according to an embodiment of this application;

FIG. 4B is a second schematic diagram of determining a target area and afocusing area according to an embodiment of this application;

FIG. 5A is a first schematic diagram of capturing a sub-image accordingto an embodiment of this application;

FIG. 5B is a second schematic diagram of capturing a sub-image accordingto an embodiment of this application;

FIG. 6A is a first schematic diagram of an operation of selecting atarget object according to an embodiment of this application;

FIG. 6B is a first schematic diagram of displaying a second previewimage according to an embodiment of this application;

FIG. 7A is a second schematic diagram of an operation of selecting atarget object according to an embodiment of this application;

FIG. 7B is a second schematic diagram of displaying a second previewimage according to an embodiment of this application;

FIG. 8 is a schematic structural diagram of a focusing apparatusaccording to an embodiment of this application;

FIG. 9 is a first schematic diagram of hardware of an electronic deviceaccording to an embodiment of this application; and

FIG. 10 is a second schematic diagram of hardware of an electronicdevice according to an embodiment of this application.

DETAILED DESCRIPTION

The following describes the technical solutions in the embodiments ofthis application with reference to the accompanying drawings in theembodiments of this application. Apparently, the described embodimentsare some but not all of the embodiments of this application. All otherembodiments obtained by a person of ordinary skill in the art based onthe embodiments of this application without creative efforts shall fallwithin the protection scope of this application.

The terms “first”, “second”, and the like in the specification andclaims of this application are used to distinguish between similarobjects instead of describing a specific order or sequence. It should beunderstood that the data used in this way is interchangeable inappropriate circumstances, so that the embodiments of this applicationcan be implemented in an order other than the order illustrated ordescribed herein. In addition, the objects distinguished by “first”,“second”, and the like usually belong to one category, and the number ofobjects is not limited. For example, there may be one or more firstobjects. In addition, in the specification and claims, “and/or”represents at least one of connected objects, and the character “/”typically represents an “or” relationship between the associatedobjects.

The following describes terms used in the embodiments of the presentapplication.

Zoom: Zoom usually means changing the focal length of a lens through achange of a lens combination, to change an angle of view. A longer focallength of the lens indicates a larger zoom ratio, a smaller angle ofview, a smaller quantity of scenes that can be included in an image, andthat the image looks closer. A shorter focal short of the lens indicatesa smaller zoom ratio, a greater angle of view, a larger quantity ofscenes that can be included in an image, and that the image looksfarther away. For example, an electronic device provides 0.5×, 1×, and2×. 1× indicates 1× zoom, and corresponds to a conventionalphotographing mode. 0.5× indicates 0.5× zoom, and corresponds to apanoramic photographing mode. Compared with 1×, a size of a photographedscene is halved. 2× indicates 2× zoom, and corresponds to a closephotographing mode. Compared with 1×, a size of a photographed scene isdoubled.

Focusing: Focusing means changing an image distance by adjusting adistance between an imaging plane and a lens without changing a focallength of the lens, so that a distance between the imaging plane and anoptical center is equal to the image distance, and an image of an objectcan be clearly formed on a photosensitive element. A process ofadjusting the lens for clear imaging of the shooting object is afocusing process. If an imaging location deviates from a plane on whichthe photosensitive element is located, a formed image is blurry, thatis, an out-of-focus phenomenon occurs during photographing.

A zoom-in (zoom in) operation means increasing the zoom ratio of a lensto reduce a photographing angle of view, so as to increase a size of ascene in a photographing image. A zoom-out (zoom out) operation meansreducing the zoom ratio of a lens to increase a photographing angle ofview, so as to reduce a size of a scene in a photographing image.

It should be noted that identifiers in the embodiments of thisapplication are used for indicating text, symbols, images, and the likeof information, controls or other containers may be used as carriers fordisplaying information, and the identifiers include but are not limitedto text identifiers, symbol identifiers, and image identifiers.

The embodiments of this application provide a focusing method. Firstinput may be received in a case that a first preview image capturedbased on a first zoom ratio is displayed, where the first input is usedfor triggering an update of the first zoom ratio to a second zoom ratio,the first zoom ratio is less than the second zoom ratio, and the firstpreview image includes an image of a target object. N images arecaptured based on the first zoom ratio in response to the first input.An image of the target object is captured from each of the N imagesbased on the second zoom ratio, to obtain N sub-images. The N sub-imagesare synthesized into a second preview image, and the second previewimage is displayed. In this solution, the first preview image capturedbased on the first zoom ratio includes the image of the target object.Therefore, when a user increases a zoom ratio of a lens from the firstzoom ratio to the second zoom ratio, a plurality of images may becaptured based on the first zoom ratio, a sub-image of the target objectis captured from each of the plurality of images based on the secondzoom ratio, and a plurality of captured sub-images are synthesized intothe second preview image. In this way, after zoom-focusing is performed,the image of the target object can be located in a center area of thesecond preview image, and the user does not need to manually change alocation of a terminal device, thereby simplifying a zoom-focusingprocess.

The following describes in detail a focusing method and apparatus and anelectronic device in the embodiments of this application with referenceto the accompanying drawings and by using embodiments and applicationscenarios thereof.

FIG. 1 shows a focusing method according to an embodiment of thisapplication. The method may include the following step 101 to step 104.

Step 101: An electronic device receives a first input in a case that afirst preview image captured based on a first zoom ratio is displayed.

The first input may be used for triggering an update of the first zoomratio to a second zoom ratio, where the first zoom ratio is less thanthe second zoom ratio. That is, the first input is input for increasinga zoom ratio. The first preview image includes an image of a targetobject.

Usually, after the electronic device runs a camera application inresponse to input performed by a user on a camera application icon byusing a finger or a touch apparatus such as a stylus, or in responseinput performed by a user on a camera application control in anapplication, the electronic device captures a preview image at aninterval of preset time based on a preset target zoom ratio, and updatesdisplay of a preview image on a preview interface of the cameraapplication.

In some embodiments, the target object may be a person, a building, ananimal, a plant, natural scenery, or the like. This is not limited inembodiments of this application. The first preview image may includeimages of a plurality of shooting objects, and the target object may beat least one of the plurality of shooting objects.

In some embodiments, the first zoom ratio is the target zoom ratio, thatis, the first preview image is a preview image captured based on thepreset target zoom ratio; or the first zoom ratio is a zoom ratio otherthan the target zoom ratio, that is, the first preview image is apreview image captured based on a first zoom ratio manually set by theuser.

For example, as shown in FIG. 2 , the preview interface of the cameraapplication includes a preview image 021 and a plurality of functioncontrols such as a zoom control, a panorama control, a beauty control, aphoto control, and a video control. The zoom control includes a progressbar 022 and an indicator control 023. In some embodiments, when the userdrags the indicator control 023 on the progress bar 022 along adirection from left to right, the electronic device increases a zoomratio of a lens in response to the drag operation, to reduce aphotographing angle of view of a camera, and increase a size of aphotographed scene in a preview image; or when the user drags theindicator control 023 on the progress bar 022 along a direction fromright to left, the electronic device reduces a zoom ratio of a lens inresponse to the drag operation, to increase a photographing angle ofview of a camera, and reduce a size of a photographed scene in a previewimage.

Step 102: The electronic device captures N images based on the firstzoom ratio in response to the first input.

In some embodiments of this application, N is an integer greater than orequal to 2. The electronic device may capture a plurality of imagesbased on the first zoom ratio. This avoids blurring or shadowing of anindividual image caused by manual shaking of the user or movement of theshooting object, and further avoids poor image quality of a secondpreview image obtained through synthesis based on the individual image.That is, a plurality of images are captured, so that image quality ofthe second preview image obtained through synthesis based on thecaptured images can be improved. It can be understood that a largervalue N indicates a larger quantity of captured second images and asmaller error caused by accidental factors such as shaking of the user,so that an image of a target shooting object in the second preview imagefinally obtained through synthesis better meets a zoom requirement ofthe user. For steps of obtaining the second preview image throughsynthesis based on captured images, refer to descriptions in thefollowing embodiments. Details are not described herein.

In some embodiments, the value N may be preset in a system, or may bepreset by the user. This is not limited in embodiments of thisapplication.

In some embodiments, a preset zoom ratio is set, and the preset zoomratio is greater than the preset target zoom ratio. When the zoom ratioof the electronic device is greater than or equal to the preset zoomratio, it can be determined that the user is performing a zoom-inoperation on a preview image. Assuming that an object of the user'sinterest is not located in a center area of a preview interface at aninitial moment, if a focusing method provided in the conventionaltechnology is used for performing zoom-in on the preview interface, theobject of the user's interest may move out of the preview interface,that is, a zoom requirement of the user cannot be met. Therefore, thefocusing method provided in embodiments of this application may be usedfor performing zoom-in on the preview interface. That is, step 102 mayinclude: In a case that the second zoom ratio is greater than or equalto the preset zoom ratio, the electronic device captures the N imagesbased on the first zoom ratio in response to the first input.

Further, after the first input is received, when the zoom ratio of theelectronic device is less than the preset zoom ratio, a zoom-in degreeof a preview image is small. In this case, a zoom requirement of theuser can also be met in a case that the focusing method provided in theconventional technology is used for performing zoom-in on the previewinterface. That is, the focusing method provided in embodiments of thisapplication may further include: In a case that the second zoom ratio isless than the preset zoom ratio, the electronic device captures an imagebased on the second zoom ratio in response to the first input.

For example, it is assumed that the target zoom ratio is 1× and thepreset zoom ratio is 1.5×. At an initial moment, the electronic devicemay capture a preview image based on the 1× zoom ratio. Subsequently, ifthe user adjusts the zoom ratio to a 2× zoom ratio, the electronicdevice may continuously capture a plurality of images based on the 2×zoom ratio because the 2× zoom ratio is greater than the preset zoomratio; or if the user adjusts the zoom ratio to a 1.2× zoom ratio, theelectronic device may capture at least one image based on the 1.2× zoomratio because the 1.2× zoom ratio is less than the preset zoom ratio.

The focusing method provided in embodiments of this application isapplied to a zoom ratio adjustment scenario. In a case that the secondzoom ratio is greater than or equal to the preset zoom ratio, aplurality of images may be captured based on the first zoom ratio, andthe second preview image is obtained through synthesis based on thecaptured images; or in a case that the second zoom ratio is less thanthe preset zoom ratio, focusing may be performed according to aconventional focusing method. Different focusing methods may be used forzoom-focusing based on a magnitude relationship between the second zoomratio and the preset zoom ratio, that is, a zoom-in degree of a previewimage, thereby improving flexibility and diversity of zoom-focusing.

In addition, after receiving the first input from the user, and beforecapturing the N images based on the first zoom ratio, the electronicdevice may output prompt information to prompt the user to keep acurrent holding gesture, so that a spatial location and a spatialposture of the electronic device can remain unchanged. In this way, itcan be ensured that locations of the image of the target object in the Nimages are the same as or similar to a location of the image of thetarget object in the first preview image, so that accuracy of thezoom-focusing method provided in this application can be improved.

Step 103: The electronic device captures an image of the target objectfrom each of the N images based on the second zoom ratio, to obtain Nsub-images.

In some embodiments, in a case that the first preview image capturedbased on the first zoom ratio is displayed, the user may perform inputon the first preview image, to select the target object from a pluralityof shooting objects recognized from the first preview image, andcalculate a location of an image including the target object in thefirst preview image and a size of the image of the target object. Referto descriptions in the following embodiments. Details are not describedherein.

Therefore, after capturing, based on the first zoom ratio, the N imagesincluding the image of the target object, for each of the N images, theelectronic device may capture an image of the target object from theimage based on the second zoom ratio, a size of the image, and the imageof the target object in the first preview image.

Step 103 is described by using an example in which an i^(th) image iscaptured from the N images. Step 103 may include step a, step b, step c,and step d, or include step a, step b, step c, and step e. That is, oneof step d or step e is performed.

Step a: The electronic device determines, in the i^(th) image of the Nimages, a target area corresponding to the target object, where a sizeof the target area is equal to that of a first area, the first area isan area corresponding to the target object in the first preview image,and a value of i ranges from 1 to N.

It should be noted that, that “the first area is an area correspondingto the target object in the first preview image” means that an image ofthe first area is the image of the target object in the first previewimage. That is, if the image of the first area is captured, the capturedimage is the image of the target object.

In some embodiments, sizes of the first preview image and each of the Nimages are the same. For example, sizes of the first preview image andthe N images are 640p×480p.

In some embodiments of this application, the electronic device mayobtain information about the first area by using a preset algorithm, andthe information about the first area may be used for indicating alocation and a size of the image of the target object in the firstpreview image. Because the sizes of the first preview image and each ofthe N images are the same, the electronic device may determine, in thei^(th) image of the N images based on the information about the firstarea, the target area corresponding to the target object. A location ofthe image of the target object in the i^(th) image is the same as thelocation of the image of the target object in the first preview image,and a size of the image of the target object in the i^(th) image is thesame as the size of the image of the target object in the first previewimage.

For example, the target object is a “person”. It is assumed that thefirst preview image and the N images have a width of W and a height ofH, and use a same coordinate system. As shown in FIG. 3 , an image ofthe “person” is in an area 031 in the first preview image, andcoordinates of four vertices of the area 031 are (X0, Y0), (X0+X, Y0),(X0, Y0+Y), and (X0+X, Y0+Y). As shown in FIG. 4A or FIG. 4B, the imageof the “person” is in an area 032 in the i^(th) image of the N imagescaptured based on the second zoom ratio, and coordinates of fourvertices of the area 032 are (X0, Y0), (X0+X, Y0), (X0, Y0+Y), and(X0+X, Y0+Y).

Step b: The electronic device determines a zoom area in the i^(th) imagebased on the second zoom ratio, a width of the i^(th) image, and aheight of the i^(th) image, where a center point of the zoom areacoincides with a center point of the target area.

In some embodiments, the target area and the zoom area in the i^(th)image are rectangular areas, or the target area and the zoom area in thei^(th) image are circular areas. In some embodiments, the target areaand the zoom area may be in another shape. This is not limited inembodiments of this application. The i^(th) image is any one of the Nimages.

For example, the target area and the zoom area of the i^(th) image arerectangular areas. The center of the target area is an intersection oftwo diagonal lines of a rectangular area, and a center of the zoom areais an intersection of two diagonal lines of another rectangular area.Center points of the two rectangular areas coincide with each other. Itcan be understood that, because the center point of the zoom areacoincides with the center point of the target area and both the zoomarea and the target area are images of the target object, the targetobject can be at a center location in a preview image obtained throughfocusing.

In some embodiments, an implementation of determining, by the electronicdevice, a size of the zoom area in the i^(th) image is as follows:determining a first ratio of the width of the i^(th) image to the secondzoom ratio as a width of the zoom area of the i^(th) image; anddetermining a second ratio of the height of the i^(th) image to thesecond zoom ratio as a height of the zoom area of the i^(th) image.

It is assumed that the width of the i^(th) image is denoted as W, theheight of the i^(th) image is denoted as H, the second zoom ratio isdenoted as zoomratio, the width of the zoom area in the i^(th) image isdenoted as Cropwidth, and the height of the zoom area in the i^(th)image is denoted as Cropheight. In this cases: the following formulasexist:

Cropwidth=W/zoomratio; and

Cropheight=H/zoomratio.

Therefore, the width of the zoom area in the i^(th) image isW/zoomratio; and the height of the zoom area in the i^(th) image isH/zoomratio.

For example, assuming that the height of the i^(th) image is 640p, thewidth of the i^(th) image is 480p, and the second zoom ratio is 2, itcan be learned through calculation based on the foregoing formulas thatthe height of the zoom area is 320p, and the width of the zoom area is240p.

Further, to compare the zoom area with the target area by using auniform standard, the center point of the zoom area coincides with thecenter point of the target area in some embodiments of this application.It is assumed that coordinates of four vertices of the target area are(X0, Y0), (X0+X, Y0), (X0, Y0+Y), and (X0+X, Y0+Y), the width of thezoom area in the i^(th) image is Cropwidth, and the height of the zoomarea in the i^(th) image is Cropheight. In this case, coordinates offour vertices of the zoom area in the i^(th) image are(X0+X/2−Cropwidth/2, Y0+Y/2−Cropheight/2), (X0+X/2+Cropwidth/2,Y0+Y/2−Cropheight/2), (X0+X/2−Cropwidth/2, Y0+Y/2+Cropheight/2), and(X0+X/2+Cropwidth/2, Y0+Y/2+Cropheight/2).

The focusing method provided in embodiments of this application isapplied to a scenario of determining the size of the zoom area in thei^(th) image. Because the size of the i^(th) image is fixed, when theuser adjusts the electronic device to different zoom ratios, theelectronic device may determine zoom areas with different sizes in thei^(th) image based on the different zoom ratios and the size of thei^(th) image. This meets a requirement of flexibly adjusting a size of azoom area based on a zoom ratio selected by the user.

Step c: The electronic device determines whether the size of the targetarea in the i^(th) image is greater than or equal to the size of thezoom area in the i^(th) image.

A larger second zoom ratio (zoomratio) indicates a smaller width and asmaller height of the zoom area in the i^(th) image, that is, a smallerthe size of the zoom area in the i^(th) image. When a value of thesecond zoom ratio is small, the size of the target area in the i^(th)image is less than the size of the zoom area in the i^(th) image. When avalue of the second zoom ratio is large, the size of the target area inthe i^(th) image is greater than or equal to the size of the zoom areain the i^(th) image.

Step d: In a case that the size of the target area in the i^(th) imageis greater than or equal to the size of the zoom area in the i^(th)image, the electronic device captures an image of the target area as ani^(th) sub-image.

For example, as shown in FIG. 3 , the first preview image includes thefollowing shooting objects: a “person”, a “flower”, and “text”. If theuser selects a “person” corresponding to an area 031 as the targetobject and increases the zoom ratio of the electronic device to a secondzoom ratio zoomratio 1, the electronic device may capture N images. Theelectronic device may determine, based on the area 031 in the firstpreview image, a target area 032 with P2 as a center point in an i^(th)image shown in FIG. 4A.

As shown in FIG. 4A, the electronic device may calculate a widthCropwidth and a height Cropheight of a zoom area 033 with P1 as a centerpoint in the i^(th) image based on a width W and a height H of thei^(th) image and the second zoom ratio zoomratio 1. Then the electronicdevice may move the zoom area 033 from the center point P1 to the centerpoint P2, so that a center point of the moved zoom area 033 coincideswith the center point of the target area 032.

Further, assuming that coordinates of four vertices of the target areaare (X0, Y0), (X0+X, Y0), (X0, Y0+Y), and (X0+X, Y0+Y), coordinates offour vertices of the moved zoom area 033 are (X0+X/2−Cropwidth/2,Y0+Y/2−Cropheight/2), (X0+X/2+Cropwidth/2, Y0+Y/2−Cropheight/2),(X0+X/2−Cropwidth/2, Y0+Y/2+Cropheight/2), and (X0+X/2+Cropwidth/2,Y0+Y/2+Cropheight/2). As shown in FIG. 4A, a size of the target area 032is greater than a size of the zoom area 033. Therefore, as shown in FIG.5A, the electronic device may capture an image of the target area 032from the i^(th) image as an i^(th) sub-image. Then the electronic devicemay enlarge the i^(th) sub-image to a preset size, where the preset sizecorresponds to a width of W and a height of H.

Step e: In a case that the size of the target area in the i^(th) imageis less than the size of the zoom area in the i^(th) image, theelectronic device captures an image of the zoom area as an i^(th)sub-image.

For example, as shown in FIG. 3 , the first preview image includes thefollowing shooting objects: a “person”, a “flower”, and “text”. If theuser selects a “person” corresponding to an area 031 as the targetobject and increases the zoom ratio of the electronic device to a secondzoom ratio zoomratio 2, where the zoomratio 2 is greater than thezoomratio 1, the electronic device may capture N images. The electronicdevice may determine, based on the area 031 in the first preview image,a target area 032 with P2 as a center point in an i^(th) image shown inFIG. 4B.

As shown in FIG. 4B, the electronic device may calculate a widthCropwidth and a height Cropheight of a zoom area 033 with P1 as a centerpoint in the i^(th) image based on a width W and a height H of thei^(th) image and the second zoom ratio zoomratio 2. Then the electronicdevice may move the zoom area 033 from the center point P1 to the centerpoint P2, so that a center point of the moved zoom area 033 coincideswith the center point of the target area 032.

Further, assuming that coordinates of four vertices of the target areaare (X0, Y0), (X0+X, Y0), (X0, Y0+Y), and (X0+X, Y0+Y), coordinates offour vertices of the moved zoom area 033 are (X0+X/2Cropwidth/2,Y0+Y/2−Cropheight/2), (X0+X/2+Cropwidth/2, Y0+Y/2−Cropheight/2),(X0+X/2−Cropwidth/2, Y0+Y/2+Cropheight/2), and (X0+X/2+Cropwidth/2,Y0+Y/2+Cropheight/2). As shown in FIG. 4B, a size of the target area 032is less than a size of the zoom area 033. Therefore, as shown in FIG.5B, the electronic device may capture an image of the zoom area 033 fromthe i^(th) image as an i^(th) sub-image. Then the electronic device mayenlarge the i^(th) sub-image to a preset size, where the preset sizecorresponds to a width of W and a height of H.

The focusing method provided in embodiments of this application isapplied to a scenario of capturing the image of the target object fromthe i^(th) image. The target area and the zoom area that include theimage of the target object are determined in the i^(th) image, and thesize of the target area is compared with the size of the zoom area, sothat a more appropriate area can be selected from the two areas, and animage of the target object can be captured from the area. Thisfacilitates subsequent synthesis of a preview image after zooming.

Step 104: The electronic device synthesizes the N sub-images into asecond preview image, and displays the second preview image.

In some embodiments, the synthesizing the N sub-images into a secondpreview image includes:

-   -   (1) The captured N sub-images are enlarged to a preview size to        obtain N enlarged sub-images.

In some embodiments, the preview size is equal to a size of the firstpreview image.

-   -   (2) The N enlarged sub-images are processed by using a        multi-frame super-resolution algorithm, to obtain N        ultra-high-definition sub-images.

The multi-frame super-resolution algorithm is an algorithm forestimating a high-resolution image by inputting a plurality oflow-resolution images and obtaining more details through informationcomplementation of the plurality of images based on a degradation model.

In some embodiments, the multi-frame super-resolution algorithm may be abilateral TV-L1 (BTVL1) super-resolution method. In the bilateral TV-L1super-resolution method, an optical flow is used to estimate a warpingfunction. In some embodiments, the multi-frame super-resolutionalgorithm may be any other algorithm. This is not limited in embodimentsof this application.

-   -   (3) The N ultra-high-definition sub-images are synthesized into        the second preview image.

After the N ultra-high-definition sub-images with the preview size areobtained, content of the N ultra-high-definition sub-images is similar.The electronic device may first extract a feature point from eachsub-image, then compare feature points, and then combine feature pointswith best image quality. In comparison with the image of the targetobject in the first preview image, the second preview image that has ahigher resolution and that includes an enlarged image of the targetobject is obtained through synthesis.

It can be understood that, on the one hand, the N sub-images capturedfrom the N images are enlarged to the preview size, so that the imageincluding the target object can be enlarged; and on the other hand, theN sub-images are processed by using the multi-frame super-resolutionalgorithm, so that an image resolution can be increased. In this way,the N ultra-high-definition sub-images are synthesized into the secondpreview image to implement zoom-focusing.

The focusing method provided in embodiments of this application isapplied to a zoom-focusing scenario. The first preview image capturedbased on the first zoom ratio includes the image of the target object.Therefore, when the user increases the zoom ratio of the lens from thefirst zoom ratio to the second zoom ratio, a plurality of images may becaptured based on the first zoom ratio, a sub-image of the target objectis captured from each of the plurality of images based on the secondzoom ratio, and a plurality of captured sub-images are synthesized intothe second preview image. In this way, after zoom-focusing is performed,the image of the target object can be located in a center area of thesecond preview image, and the user does not need to manually change alocation of a terminal device, thereby simplifying a zoom-focusingprocess.

In some embodiments, in a case that the first preview image capturedbased on the first zoom ratio is displayed, the electronic device mayrecognize shooting objects in the first preview image, so that the userselects the target object from the shooting objects. For example, beforestep 103, the focusing method provided in some embodiments of thisapplication may further include step 105 to step 108.

Step 105: In a case that the first preview image captured based on thefirst zoom ratio is displayed, the electronic device recognizes Sshooting objects from the first preview image.

S is a positive integer.

In some implementations, in a case that the first preview image capturedbased on the first zoom ratio is displayed, the electronic device mayfirst recognize the S shooting objects from the first preview image, andthen receive first input for increasing the first zoom ratio to thesecond zoom ratio.

For example, the electronic device may detect and recognize each frameof preview image in the background, and recognize a shooting object suchas a person, a tree, a flower, text, or an animal in the image by usingan image detection and recognition algorithm In addition, the electronicdevice may calculate a location and a size of each shooting object, andstore location information of each shooting object, where locationinformation of a shooting object is used for indicating a location and asize of the shooting object.

In some implementations, in a case that the first preview image capturedbased on the first zoom ratio is displayed, the electronic device mayfirst receive first input for increasing the first zoom ratio to thesecond zoom ratio, and then recognize the S shooting objects from thefirst preview image.

Step 106: The electronic device displays S identifiers in response tothe first input.

Each identifier is used for indicating one of the S shooting objects.Identifiers in this application are used for indicating text, symbols,images, and the like of information, controls or other containers may beused as carriers for displaying information, and the identifiers includebut are not limited to text identifiers, symbol identifiers, and imageidentifiers.

For descriptions of the preset zoom ratio, refer to descriptions in theforegoing embodiments.

In a case that an operation of adjusting the zoom ratio of theelectronic device by the user is received, if the second zoom ratio isgreater than or equal to the preset zoom ratio, it can be determinedthat the user is performing a zoom-in operation, and a zoom-in degree ofa preview image is large. If a focusing method in the conventionaltechnology is used, the target object may not be located in a centerarea of a preview interface. Therefore, the focusing method provided inembodiments of this application may be used. Information for promptingthe user to select a shooting object is output, so that the user selectsa shooting object. Therefore, the electronic device may capture aplurality of images including the shooting object selected by the user,and then obtain, through synthesis, a zoom image in which an image oftarget object is located in a center area.

In some embodiments, a manner of outputting information for promptingthe user to select a shooting object includes at least one of thefollowing:

Manner 1: A prompt user interface (UI) is displayed on the first previewinterface. The prompt user interface includes the S identifiers, andeach identifier is used for indicating one of the S shooting objects.

For each of the S identifiers, in some implementations, an identifiermay be a name of a shooting object, for example, “Flower” or “Person”.When the user taps a name, a shooting object corresponding to the nameis selected. In another implementation, an identifier may be a selectionbox displayed on the first preview interface. The selection box islocated in an area in which an image of a shooting object is located.When a user taps an area in which a selection box is located, a shootingobject corresponding to the area is selected.

It should be noted that an example in which an identifier is a name isused for description in the following embodiments, but does notconstitute a limitation on embodiments of this application. Duringactual implementation, an identifier may be a selection box.

Manner 2: The electronic device plays a prompt tone, for example,sequentially plays a name of each shooting object, so that the user canselect the target object based on the prompt tone.

It should be noted that an example in which the target object isselected in the manner 1 is used for description in step 106, but doesnot constitute a limitation on embodiments of this application. Thetarget object may be selected in the manner 2.

Step 107: The electronic device receives second input performed on atarget identifier of the S identifiers.

The target identifier may be used for indicating the target object ofthe S shooting objects.

In some embodiments, the second input may be tap input, sliding input,touch-and-hold input, or the like performed on the target identifier.

Step 108: The electronic device determines the first area in the firstpreview image in response to the second input.

For example, as shown in FIG. 6A, in a case that the first preview imagecaptured based on the first zoom ratio is displayed, the electronicdevice may recognize the following shooting objects from the firstpreview image: a “person”, a “flower”, and “text”.

In a case that an operation of adjusting, by the user, the electronicdevice to the second zoom ratio is received, the electronic device maydisplay an identifier 061 of the “person”, an identifier 063 of the“flower”, and an identifier 062 of the “text” in the first preview imagein a superposed manner, so that the user selects an identifier of thetarget object from these identifiers. Assuming that the user taps theidentifier 061 of the “person”, the electronic device may determine the“person” as the target object and capture N images. After the electronicdevice obtains the second preview image according to the focusing methodprovided in the foregoing embodiment, the electronic device may displaya second preview image shown in FIG. 6B.

In addition, the electronic device may further display the followingthree options shown in FIG. 6B: “Person”, “Flower”, and “Text”. The“Person” option 064 is in bold font to prompt the user that the “person”is the target object. If the user taps “Flower”, the electronic devicemay re-obtain, based on the N images, and display a second preview imagein which the target object is the “flower”, and display the “Flower”option in bold. If the user taps “Text”, the electronic device mayre-obtain, based on the N images, and display a second preview image inwhich the target object is the “text”, and display the “Text” option inbold.

The focusing method provided in embodiments of this application isapplied to a scenario of prompting the user to select a shooting object.Objects in the first preview image are recognized, and identifiers ofthe objects are displayed. This can meet a requirement of the user forselecting a target object from the objects. Especially, in a scenario inwhich a large-screen mobile phone is held with one hand, the user canselect any object on a preview interface only by performing input on anidentifier corresponding to a shooting object in a small display range.This meets a requirement for quickly obtaining a zoom image of thetarget shooting object.

In some embodiments, the user may select a plurality of shooting objectsin step 101 to step 104. For example, it is assumed that the targetobject includes P sub-objects, the second preview image includes Psub-images, one sub-object corresponds to one preview sub-image, and Pis an integer greater than or equal to 2. Step 107 may be implemented bythe following step 107 a, and the “displaying the second preview image”in step 104 may be implemented by the following step 104 a or step 104b.

Step 107 a: The electronic device receives second input performed on Pidentifiers of the S identifiers.

The P identifiers may be used for indicating the P sub-objects.

For example, as shown in FIG. 7A, in a case that the first preview imagecaptured based on the first zoom ratio is displayed, the electronicdevice may recognize the following shooting objects from the firstpreview image: a “person”, a “flower”, and “text”. In a case that anoperation of adjusting, by the user, the electronic device to the secondzoom ratio is received, the electronic device may display an identifier071 of the “person”, an identifier 073 of the “flower”, and anidentifier 072 of the “text” (that is, S=3) in the first preview imagein a superposed manner. Assuming that the user taps the identifier 071of the “person” and the identifier 073 of the “flower” (that is, P=2),the electronic device may determine the “person” and the “flower” astarget shooting objects and capture N images.

The electronic device may capture N sub-images corresponding to the“person” from the N images according to the focusing method provided inthe foregoing embodiment, and synthesize the N sub-images correspondingto the “person” into a second preview image; and capture N sub-imagescorresponding to the “flower” from the N images, and synthesize the Nsub-images corresponding to the “flower” into another second previewimage.

Step 104 a: The electronic device sequentially displays each of the Ppreview sub-images.

In some embodiments of this application, the electronic device maydisplay one of the P preview sub-images at a time in a preset sequence.After displaying the P preview sub-images, the electronic device maysequentially re-display each of the P preview sub-images; or afterdisplaying the P preview sub-images, the electronic device may fixedlydisplay a preview sub-image, for example, the last preview sub-image.

It can be understood that, when the electronic device sequentiallydisplays each of the P preview sub-images, a display proportion of eachpreview sub-image on a screen can be increased, thereby ensuring thateach preview sub-image is displayed in a large size, and the user canconveniently view each preview sub-image.

Step 104 b: The electronic device displays a part of the P previewsub-images based on a first proportion, and displays another part of theP preview sub-images based on a second proportion.

The first proportion is greater than the second proportion.

In some embodiments, a display priority of the part of previewsub-images displayed based on the first proportion is higher than adisplay priority of the another part of preview sub-images displayedbased on the second proportion. A display priority of each previewsub-image is preset in a system or is set by the user.

It is assumed that a display priority of a preview image of the “person”is higher than a display priority of a preview image of the “flower”. Asshown in FIG. 7B, the electronic device may display the preview image ofthe “person” at a larger proportion in a first display area of a previewinterface, and display the preview image of the “flower” at a smallerproportion in a second display area. Both the first display area and thesecond display area are preset display areas, and a size of the firstdisplay area is greater than a size of the second display area.

In addition, the electronic device may further display the followingthree options shown in FIG. 7B: “Person”, “Flower”, and “Text”. The“Person” option 074 and the “Flower” option 075 are in bold font toprompt the user that the “person and the “flower” are target objects. Ifthe user taps the “Person”, “Flower”, and “Text” options, the electronicdevice may display, in three areas of the preview interface, threesecond preview images in which target objects are the “person”, the“flower”, and the “text” respectively, and display the “Person”,“Flower”, and “Text” options in bold.

It can be understood that, for different shooting objects, becausepriorities of preview sub-images corresponding to the shooting objectsare different, the preview sub-images corresponding to the differentshooting objects can be displayed based on different displayproportions, so that the user can conveniently view a preview sub-imagecorresponding to a shooting object with a higher priority.

The focusing method provided in embodiments of this application isapplied to a scenario of performing zoom-focusing on a plurality ofshooting objects. When the user selects a plurality of shooting objects,the electronic device may capture N images, and obtain, based on the Nimages, a zoom-focused preview image corresponding to each shootingobject, so that zoom-focused preview images can be displayed on thepreview interface.

It should be noted that the focusing method provided in the embodimentsof this application may be performed by a zoom-focusing apparatus, or bya control module that is in the zoom-focusing apparatus and that isconfigured to perform the focusing method. In the embodiments of thisapplication, a zoom-focusing apparatus provided in the embodiments ofthis application is described by using an example in which thezoom-focusing apparatus performs the focusing method.

As shown in FIG. 8 , an embodiment of this application further providesa zoom-focusing apparatus 800. The zoom-focusing apparatus includes areceiving module 801, a capture module 802, a processing module 803, anda display module 804.

The receiving module 801 may be configured to receive first input in acase that the display module 804 displays a first preview image capturedbased on a first zoom ratio, where the first input is used fortriggering an update of the first zoom ratio to a second zoom ratio, thefirst zoom ratio is less than the second zoom ratio, and the firstpreview image includes an image of a target object. The capture module802 may be configured to capture N images based on the first zoom ratioin response to the first input received by the receiving module 801. Theprocessing module 803 may be configured to: capture, based on the secondzoom ratio, an image of the target object from each of the N imagescaptured by the capture module 802, to obtain N sub-images, andsynthesize the N sub-images into a second preview image. The displaymodule 804 may be configured to display the second preview imageobtained by the processing module 803 through synthesis. N is an integergreater than 1.

In some embodiments, the processing module 803 may be configured to:determine, in an i^(th) image of the N images, a target areacorresponding to the target object, where a size of the target area isequal to that of a first area, the first area is an area correspondingto the target object in the first preview image, and a value of i rangesfrom 1 to N; determine a zoom area in the i^(th) image based on thesecond zoom ratio, a width of the i^(th) image, and a height of thei^(th) image, where a center point of the zoom area coincides with acenter point of the target area; and in a case that the size of thetarget area is greater than or equal a size of the zoom area, capture animage of the target area as an i^(th) sub-image; or in a case that thesize of the target area is less than a size of the zoom area, capture animage of the zoom area as an i^(th) sub-image.

In some embodiments, the processing module 803 may be configured to:determine a first ratio of the width of the i^(th) image to the secondzoom ratio as a width of the zoom area of the i^(th) image; anddetermine a second ratio of the height of the i^(th) image to the secondzoom ratio as a height of the zoom area of the i^(th) image.

In some embodiments, the processing module 803 may be configured to:before capturing the image of the target object from each of the Nimages based on the second zoom ratio, recognize S shooting objects fromthe first preview image, where S is a positive integer. The displaymodule 804 may be further configured to display S identifiers inresponse to the first input received by the receiving module 801, whereeach identifier is used for indicating one of the S shooting objects.The receiving module 801 may be further configured to receive secondinput performed on a target identifier of the S identifiers displayed bythe display module 804, where the target identifier is used forindicating the target object. The processing module 803 may be furtherconfigured to determine the first area in the first preview image inresponse to the second input received by the receiving module 801.

In some embodiments, the target object includes P sub-objects, thesecond preview image includes P sub-images, one sub-object correspondsto one preview sub-image, and P is an integer greater than or equal to2. The receiving module 801 may be configured to receive second inputperformed on P identifiers of the S identifiers, where the P identifiersare used for indicating the P sub-objects. The display module 804 may beconfigured to: sequentially display each of the P preview sub-images; ordisplay a part of the P preview sub-images based on a first proportion,and display another part of the P preview sub-images based on a secondproportion, where the first proportion is greater than the secondproportion.

In some embodiments, the capture module 802 may be configured to: in acase that the second zoom ratio is greater than or equal to the presetzoom ratio, capture the N images based on the first zoom ratio inresponse to the first input.

In the zoom-focusing apparatus provided in embodiments of thisapplication, the first preview image captured based on the first zoomratio includes the image of the target object. Therefore, when a userincreases a zoom ratio of a lens from the first zoom ratio to the secondzoom ratio, the apparatus may capture a plurality of images based on thefirst zoom ratio, capture a sub-image of the target object from each ofthe plurality of images based on the second zoom ratio, and synthesize aplurality of captured sub-images into the second preview image. In thisway, after zoom-focusing is performed, the image of the target objectcan be located in a center area of the second preview image, and theuser does not need to manually change a location of a terminal device,thereby simplifying a zoom-focusing process.

The zoom-focusing apparatus in embodiments of this application may be anapparatus, or may be a component, an integrated circuit, or a chip in aterminal. The apparatus may be a mobile electronic device, or may be anon-mobile electronic device. For example, the mobile electronic devicemay be a mobile phone, a tablet computer, a notebook computer, a palmtopcomputer, a vehicle-mounted electronic device, a wearable device, anultra-mobile personal computer (UMPC), a netbook, or a personal digitalassistant (PDA), and the non-mobile electronic device may be a server, anetwork attached storage (NAS), a personal computer (PC), a television(TV), a teller machine, or a self-service machine. This is notspecifically limited in embodiments of this application.

The zoom-focusing apparatus in embodiments of this application may be anapparatus with an operating system. The operating system may be anAndroid operating system, may be an iOS operating system, or may beanother possible operating system. This is not specifically limited inembodiments of this application.

The zoom-focusing apparatus provided in embodiments of this applicationis capable of implementing the processes implemented in the methodembodiments of FIG. 1 to FIG. 7 . To avoid repetition, details are notdescribed herein again.

As shown in FIG. 9 , an embodiment of this application further providesan electronic device 900, including a processor 901, a memory 902, and aprogram or instructions stored in the memory 902 and capable of runningon the processor 901. When the program or instructions are executed bythe processor 901, the processes of the foregoing focusing methodembodiments are implemented, with the same technical effects achieved.To avoid repetition, details are not described herein again.

It should be noted that the electronic device in embodiments of thisapplication includes the foregoing mobile electronic device andnon-mobile electronic device.

FIG. 10 is a schematic diagram of a hardware structure of an electronicdevice for implementing the embodiments of this application.

The electronic device 1000 includes but is not limited to componentssuch as a radio frequency unit 1001, a network module 1002, an audiooutput unit 1003, an input unit 1004, a sensor 1005, a display unit1006, a user input unit 1007, an interface unit 1008, a memory 1009, anda processor 1010.

A person skilled in the art can understand that the electronic device1000 may further include a power supply (for example, a battery) thatsupplies power to each component. The power supply may be logicallyconnected to the processor 1010 by using a power management system, toimplement functions such as charging management, discharging management,and power consumption management by using the power management system.The structure of the electronic device shown in FIG. 10 does notconstitute a limitation on the electronic device. The electronic devicemay include more or fewer components than those shown in the figure, orsome components may be combined, or there may be a different componentlayout. Details are not described herein again.

The user input unit 1007 may be configured to receive first input in acase that the display unit 1006 displays a first preview image capturedbased on a first zoom ratio, where the first input is used fortriggering an update of the first zoom ratio to a second zoom ratio, thefirst zoom ratio is less than the second zoom ratio, and the firstpreview image includes an image of a target object. The input unit 1004may be configured to capture N images based on the first zoom ratio inresponse to the first input received by the user input unit 1007. Theprocessor 1010 may be configured to: capture, based on the second zoomratio, an image of the target object from each of the N images capturedby the input unit 1004, to obtain N sub-images, and synthesize the Nsub-images into a second preview image. The display unit 1006 may beconfigured to display the second preview image obtained by the processor1010 through synthesis. N is an integer greater than 1.

In some embodiments, the processor 1010 may be configured to: determine,in an i^(th) image of the N images, a target area corresponding to thetarget object, where a size of the target area is equal to that of afirst area, the first area is an area corresponding to the target objectin the first preview image, and a value of i ranges from 1 to N;determine a zoom area in the i^(th) image based on the second zoomratio, a width of the i^(th) image, and a height of the i^(th) image,where a center point of the zoom area coincides with a center point ofthe target area; and in a case that the size of the target area isgreater than or equal a size of the zoom area, capture an image of thetarget area as an i^(th) sub-image; or in a case that the size of thetarget area is less than a size of the zoom area, capture an image ofthe zoom area as an i^(th) sub-image.

In some embodiments, the processor 1010 may be configured to: determinea first ratio of the width of the i^(th) image to the second zoom ratioas a width of the zoom area of the i^(th) image; and determine a secondratio of the height of the i^(th) image to the second zoom ratio as aheight of the zoom area of the i^(th) image.

In some embodiments, the processor 1010 may be configured to: beforecapturing the image of the target object from each of the N images basedon the second zoom ratio, recognize S shooting objects from the firstpreview image, where S is a positive integer. The display unit 1006 maybe further configured to display S identifiers in response to the firstinput received by the user input unit 1007, where each identifier isused for indicating one of the S shooting objects. The user input unit1007 may be further configured to receive second input performed on atarget identifier of the S identifiers displayed by the display unit1006, where the target identifier is used for indicating the targetobject. The processor 1010 may be further configured to determine thefirst area in the first preview image in response to the second inputreceived by the user input unit 1007.

In some embodiments, the target object includes P sub-objects, thesecond preview image includes P sub-images, one sub-object correspondsto one preview sub-image, and P is an integer greater than or equal to2. The user input unit 1007 may be configured to receive second inputperformed on P identifiers of the S identifiers, where the P identifiersare used for indicating the P sub-objects. The display unit 1006 may beconfigured to: sequentially display each of the P preview sub-images; ordisplay a part of the P preview sub-images based on a first proportion,and display another part of the P preview sub-images based on a secondproportion, where the first proportion is greater than the secondproportion.

In some embodiments, the input unit 1004 may be configured to: in a casethat the second zoom ratio is greater than or equal to the preset zoomratio, capture the N images based on the first zoom ratio in response tothe first input.

In the electronic device provided in embodiments of this application,the first preview image captured based on the first zoom ratio includesthe image of the target object. Therefore, when a user increases a zoomratio of a lens from the first zoom ratio to the second zoom ratio, thedevice may capture a plurality of images based on the first zoom ratio,capture a sub-image of the target object from each of the plurality ofimages based on the second zoom ratio, and synthesize a plurality ofcaptured sub-images into the second preview image. In this way, afterzoom-focusing is performed, the image of the target object can belocated in a center area of the second preview image, and the user doesnot need to manually change a location of a terminal device, therebysimplifying a zoom-focusing process.

It should be understood that, in embodiments of this application, theinput unit 1004 may include a graphics processing unit (GPU) 10041 and amicrophone 10042. The graphics processing unit 10041 processes imagedata of a static picture or a video that is obtained by an image captureapparatus (for example, a camera) in a video capture mode or an imagecapture mode. The display unit 1006 may include a display panel 10061.The display panel 10061 may be configured in a form of a liquid crystaldisplay, an organic light-emitting diode, or the like. The user inputunit 1007 includes a touch panel 10071 and other input devices 10072.The touch panel 10071 is also referred to as a touchscreen. The touchpanel 10071 may include two parts: a touch detection apparatus and atouch controller. The other input devices 10072 may include but are notlimited to a physical keyboard, a function key (such as a volume controlkey or an on/off key), a trackball, a mouse, and a joystick. Details arenot described herein. The memory 1009 may be configured to storesoftware programs and various data, including but not limited to anapplication program and an operating system. The processor 1010 mayintegrate an application processor and a modem processor. Theapplication processor mainly processes an operating system, a userinterface, an application program, and the like. The modem processormainly processes wireless communication. It can be understood that themodem processor may not be integrated in the processor 1010.

An embodiment of this application further provides a readable storagemedium. The readable storage medium stores a program or instructions.When the program or instructions are executed by a processor, theprocesses of the foregoing focusing method embodiments are implemented,with the same technical effects achieved. To avoid repetition, detailsare not described herein again.

The processor is a processor in the electronic device in the foregoingembodiments. The readable storage medium includes a computer-readablestorage medium, for example, a computer read-only memory (ROM), a randomaccess memory (RAM), a magnetic disk, or an optical disc.

An embodiment of this application further provides a chip. The chipincludes a processor and a communications interface. The communicationsinterface is coupled to the processor. The processor is configured torun a program or instructions, to implement the processes of theforegoing focusing method embodiments, with the same technical effectsachieved. To avoid repetition, details are not described herein again.

It should be understood that the chip provided in embodiments of thisapplication may also be referred to as a system-level chip, a system onchip, a chip system, a system-on-a-chip, or the like.

It should be noted that the terms “include”, “comprise”, or any othervariation thereof in this specification are intended to cover anon-exclusive inclusion, so that a process, a method, an object, or anapparatus that includes a list of elements not only includes thoseelements but also includes other elements that are not expressly listed,or further includes elements inherent to such a process, method, object,or apparatus. In absence of more constraints, an element preceded by“includes a . . . ” does not preclude the existence of other identicalelements in the process, method, article, or apparatus that includes theelement. In addition, it should be noted that the scope of the methodand apparatus in the implementations of this application is not limitedto performing functions in the shown or described order, but may alsoinclude performing functions in a substantially simultaneous manner orin a reverse order depending on the functions involved. For example, thedescribed method may be performed in an order different from thatdescribed, and steps may be added, omitted, or combined. In addition,features described with reference to some examples may be combined inother examples.

According to the foregoing descriptions of the implementations, a personskilled in the art can clearly understand that the methods in theforegoing embodiments may be implemented by using software incombination with a necessary common hardware platform, or may beimplemented by using hardware. Based on such an understanding, thetechnical solutions of this application essentially or the partcontributing to the conventional technology may be implemented in a formof a software product. The computer software product may be stored in astorage medium (for example, a ROM/RAM, a magnetic disk, or a compactdisc), and includes several instructions for instructing a terminal(which may be a mobile phone, a computer, a server, a network device, orthe like) to perform the methods in the embodiments of this application.

The foregoing describes the embodiments of this application withreference to the accompanying drawings. However, this application is notlimited to the foregoing implementations. The foregoing implementationsare merely illustrative rather than restrictive. As instructed by thisapplication, a person of ordinary skill in the art may develop manyother manners without departing from principles of this application andthe protection scope of the claims, and all such manners fall within theprotection scope of this application.

What is claimed is:
 1. A focusing method, comprising: receiving firstinput when a first preview image captured based on a first zoom ratio isdisplayed, wherein the first input is used for triggering an update ofthe first zoom ratio to a second zoom ratio, the first zoom ratio isless than the second zoom ratio, and the first preview image comprisesan image of a target object; capturing N images based on the first zoomratio in response to the first input; capturing an image of the targetobject from each of the N images based on the second zoom ratio, toobtain N sub-images; and synthesizing the N sub-images into a secondpreview image, and displaying the second preview image, wherein N is aninteger greater than
 1. 2. The focusing method according to claim 1,wherein capturing the image of the target object from each of the Nimages based on the second zoom ratio, to obtain N sub-images comprises:determining, in an i^(th) image of the N images, a target areacorresponding to the target object, wherein a size of the target area isequal to that of a first area, the first area is an area correspondingto the target object in the first preview image, and a value of i rangesfrom 1 to N; determining a zoom area in the i^(th) image based on thesecond zoom ratio, a width of the i^(th) image, and a height of thei^(th) image, wherein a center point of the zoom area coincides with acenter point of the target area; and when the size of the target area isgreater than or equal to a size of the zoom area, capturing an image ofthe target area as an i^(th) sub-image; or when the size of the targetarea is less than a size of the zoom area, capturing an image of thezoom area as an i^(th) sub-image.
 3. The focusing method according toclaim 2, wherein determining the zoom area in the i^(th) image based onthe second zoom ratio, the width of the i^(th) image, and the height ofthe i^(th) image comprises: determining a first ratio of the width ofthe i^(th) image to the second zoom ratio as a width of the zoom area ofthe i^(th) image; and determining a second ratio of the height of thei^(th) image to the second zoom ratio as a height of the zoom area ofthe i^(th) image.
 4. The focusing method according to claim 2, whereinbefore capturing the image of the target object from each of the Nimages based on the second zoom ratio, to obtain N sub-images, thefocusing method further comprises: recognizing S shooting objects fromthe first preview image, wherein S is a positive integer; displaying Sidentifiers in response to the first input, wherein each identifier isused for indicating one of the S shooting objects; receiving secondinput performed on a target identifier of the S identifiers, wherein thetarget identifier is used for indicating the target object; anddetermining the first area in the first preview image in response to thesecond input.
 5. The focusing method according to claim 4, wherein thetarget object comprises P sub-objects, the second preview imagecomprises P sub-images, one sub-object corresponds to one previewsub-image, and P is an integer greater than or equal to 2; whereinreceiving the second input performed on the target identifier of the Sidentifiers comprises: receiving second input performed on P identifiersof the S identifiers, wherein the P identifiers are used for indicatingthe P sub-objects; and wherein displaying the second preview imagecomprises: sequentially displaying each of the P preview sub-images; ordisplaying a part of the P preview sub-images based on a firstproportion, and displaying another part of the P preview sub-imagesbased on a second proportion, wherein the first proportion is greaterthan the second proportion.
 6. The focusing method according to claim 1,wherein capturing the N images based on the first zoom ratio in responseto the first input comprises: when the second zoom ratio is greater thanor equal to a preset zoom ratio, capturing the N images based on thefirst zoom ratio in response to the first input.
 7. An electronicdevice, comprising a processor and a memory storing a program or aninstruction that is capable of running on the processor, wherein theprogram or the instruction, when executed by the processor, causes theelectronic device to perform: receiving first input when a first previewimage captured based on a first zoom ratio is displayed, wherein thefirst input is used for triggering an update of the first zoom ratio toa second zoom ratio, the first zoom ratio is less than the second zoomratio, and the first preview image comprises an image of a targetobject; capturing N images based on the first zoom ratio in response tothe first input; capturing an image of the target object from each ofthe N images based on the second zoom ratio, to obtain N sub-images; andsynthesizing the N sub-images into a second preview image, anddisplaying the second preview image, wherein N is an integer greaterthan
 1. 8. The electronic device according to claim 7, wherein capturingthe image of the target object from each of the N images based on thesecond zoom ratio, to obtain N sub-images comprises: determining, in ani^(th) image of the N images, a target area corresponding to the targetobject, wherein a size of the target area is equal to that of a firstarea, the first area is an area corresponding to the target object inthe first preview image, and a value of i ranges from 1 to N;determining a zoom area in the i^(th) image based on the second zoomratio, a width of the i^(th) image, and a height of the i^(th) image,wherein a center point of the zoom area coincides with a center point ofthe target area; and when the size of the target area is greater than orequal to a size of the zoom area, capturing an image of the target areaas an i^(th) sub-image; or when the size of the target area is less thana size of the zoom area, capturing an image of the zoom area as ani^(th) sub-image.
 9. The electronic device according to claim 8, whereindetermining the zoom area in the i^(th) image based on the second zoomratio, the width of the i^(th) image, and the height of the i^(th) imagecomprises: determining a first ratio of the width of the i^(th) image tothe second zoom ratio as a width of the zoom area of the i^(th) image;and determining a second ratio of the height of the i^(th) image to thesecond zoom ratio as a height of the zoom area of the i^(th) image. 10.The electronic device according to claim 8, wherein before capturing theimage of the target object from each of the N images based on the secondzoom ratio, to obtain N sub-images, the program or the instruction, whenexecuted by the processor, causes the electronic device to furtherperform: recognizing S shooting objects from the first preview image,wherein S is a positive integer; displaying S identifiers in response tothe first input, wherein each identifier is used for indicating one ofthe S shooting objects; receiving second input performed on a targetidentifier of the S identifiers, wherein the target identifier is usedfor indicating the target object; and determining the first area in thefirst preview image in response to the second input.
 11. The electronicdevice according to claim 10, wherein the target object comprises Psub-objects, the second preview image comprises P sub-images, onesub-object corresponds to one preview sub-image, and P is an integergreater than or equal to 2; wherein receiving the second input performedon the target identifier of the S identifiers comprises: receivingsecond input performed on P identifiers of the S identifiers, whereinthe P identifiers are used for indicating the P sub-objects; and whereindisplaying the second preview image comprises: sequentially displayingeach of the P preview sub-images; or displaying a part of the P previewsub-images based on a first proportion, and displaying another part ofthe P preview sub-images based on a second proportion, wherein the firstproportion is greater than the second proportion.
 12. The electronicdevice according to claim 7, wherein capturing the N images based on thefirst zoom ratio in response to the first input comprises: when thesecond zoom ratio is greater than or equal to a preset zoom ratio,capturing the N images based on the first zoom ratio in response to thefirst input.
 13. A non-transitory computer-readable storage medium,storing a program or an instruction, wherein the program or theinstruction, when executed by a processor, causes the processor toperform: receiving first input when a first preview image captured basedon a first zoom ratio is displayed, wherein the first input is used fortriggering an update of the first zoom ratio to a second zoom ratio, thefirst zoom ratio is less than the second zoom ratio, and the firstpreview image comprises an image of a target object; capturing N imagesbased on the first zoom ratio in response to the first input; capturingan image of the target object from each of the N images based on thesecond zoom ratio, to obtain N sub-images; and synthesizing the Nsub-images into a second preview image, and displaying the secondpreview image, wherein N is an integer greater than
 1. 14. Thenon-transitory computer-readable storage medium according to claim 13,wherein capturing the image of the target object from each of the Nimages based on the second zoom ratio, to obtain N sub-images comprises:determining, in an i^(th) image of the N images, a target areacorresponding to the target object, wherein a size of the target area isequal to that of a first area, the first area is an area correspondingto the target object in the first preview image, and a value of i rangesfrom 1 to N; determining a zoom area in the i^(th) image based on thesecond zoom ratio, a width of the i^(th) image, and a height of thei^(th) image, wherein a center point of the zoom area coincides with acenter point of the target area; and when the size of the target area isgreater than or equal to a size of the zoom area, capturing an image ofthe target area as an i^(th) sub-image; or when the size of the targetarea is less than a size of the zoom area, capturing an image of thezoom area as an i^(th) sub-image.
 15. The non-transitorycomputer-readable storage medium according to claim 14, whereindetermining the zoom area in the i^(th) image based on the second zoomratio, the width of the i^(th) image, and the height of the i^(th) imagecomprises: determining a first ratio of the width of the i^(th) image tothe second zoom ratio as a width of the zoom area of the i^(th) image;and determining a second ratio of the height of the i^(th) image to thesecond zoom ratio as a height of the zoom area of the i^(th) image. 16.The non-transitory computer-readable storage medium according to claim14, wherein before capturing the image of the target object from each ofthe N images based on the second zoom ratio, to obtain N sub-images, theprogram or the instruction, when executed by the processor, causes theprocessor to further perform: recognizing S shooting objects from thefirst preview image, wherein S is a positive integer; displaying Sidentifiers in response to the first input, wherein each identifier isused for indicating one of the S shooting objects; receiving secondinput performed on a target identifier of the S identifiers, wherein thetarget identifier is used for indicating the target object; anddetermining the first area in the first preview image in response to thesecond input.
 17. The non-transitory computer-readable storage mediumaccording to claim 16, wherein the target object comprises Psub-objects, the second preview image comprises P sub-images, onesub-object corresponds to one preview sub-image, and P is an integergreater than or equal to 2; wherein receiving the second input performedon the target identifier of the S identifiers comprises: receivingsecond input performed on P identifiers of the S identifiers, whereinthe P identifiers are used for indicating the P sub-objects; and whereindisplaying the second preview image comprises: sequentially displayingeach of the P preview sub-images; or displaying a part of the P previewsub-images based on a first proportion, and displaying another part ofthe P preview sub-images based on a second proportion, wherein the firstproportion is greater than the second proportion.
 18. The non-transitorycomputer-readable storage medium according to claim 13, whereincapturing the N images based on the first zoom ratio in response to thefirst input comprises: when the second zoom ratio is greater than orequal to a preset zoom ratio, capturing the N images based on the firstzoom ratio in response to the first input.
 19. A chip, comprising aprocessor and a communication interface coupled to the processor,wherein the processor is configured to execute computer instructions toperform the focusing method according to claim
 1. 20. The chip accordingto claim 19, wherein capturing the image of the target object from eachof the N images based on the second zoom ratio, to obtain N sub-imagescomprises: determining, in an i^(th) image of the N images, a targetarea corresponding to the target object, wherein a size of the targetarea is equal to that of a first area, the first area is an areacorresponding to the target object in the first preview image, and avalue of i ranges from 1 to N; determining a zoom area in the i^(th)image based on the second zoom ratio, a width of the i^(th) image, and aheight of the i^(th) image, wherein a center point of the zoom areacoincides with a center point of the target area; and when the size ofthe target area is greater than or equal to a size of the zoom area,capturing an image of the target area as an i^(th) sub-image; or whenthe size of the target area is less than a size of the zoom area,capturing an image of the zoom area as an i^(th) sub-image.